// pages/newlocal/index.js
// import Toast from '//miniprogram_npm/@vant/weapp/dist/toast/toast';
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
const SERVER = require('../../utils/index');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
    show:false,
    region: ['', '', ''],
    currentZone:'',
    name:'',//姓名
    number:'',//电话
    dian:false,
    text:''
  },
  text(e){
    this.setData({
      text:e.detail.value
    })

  },
  butt(){
    var that=this
    let param = {
      countryType : 0,
      isDefault : this.data.dian==true?'0':'1',
      phone : this.data.number,
      receiver:this.data.name,
      provinceName:this.data.region[0],
      regionName:this.data.region[0]+this.data.region[1]+this.data.region[2],
      receiveAddress:this.data.text

    }
    wx.request({//首页数据
      url: '' + SERVER.SERVER_DIMAIN + '/customer/deliveryaddress/save', 
      data: JSON.stringify(param),
      header: {
        'content-type': 'application/json' ,
        "TENANT-ID":"2",
        "Authorization":"Basic YXBwOmFwcA==",
        "DEVICE_TYPE":'IOS'
      },
      method: 'post',
      success: function (res) {
        console.log(res)
       that.setData({
         list:res.data.data.records
       })
  
       
      }
    });
  },
  dian(){
this.setData({
  dian:!this.data.dian
})
  },
  chnge(e){
    this.setData({
      name:e.detail.value
    })

  },
  chnges(e){
    this.setData({
      number:e.detail.value
    })

  },
  bindRegionChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      region: e.detail.value
    })
  },
  onChange(event) {
    const { picker, value, index } = event.detail;
    Toast(`当前值：${value}, 当前索引：${index}`);
  },
  onClose() {
    this.setData({ show: false });
  },
  showPopup() {
    
    this.setData({ show: true });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})